package org.example.y24.m12;


import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

public class Courses {
    public static final Integer COURSE_NUMBER = 5;
    private static Course[][] courses = new Course[7][COURSE_NUMBER];//课程表
    private Long day;//开学日期


    public Courses() {
        Day();
        createCorse();
    }
    private void Day() {
        Integer[] startDate = new Integer[3];//开学日期
        startDate[0] = 2024;
        startDate[1] = 8;
        startDate[2] = 26;
        LocalDate start = LocalDate.of(startDate[0], startDate[1], startDate[2]);
        LocalDate end = LocalDate.now();
        day = ChronoUnit.DAYS.between(start, end);
    }

    private void createCorse() {
        Mon(0);
        Tues(1);
        Wed(2);
        Thur(3);
        Fri(4);
        Sat(5);
        Sun(6);
    }

    private void Sun(int col) {
        for (int i = 0; i < 5; i++) {
            courses[col][i] = null;
        }
    }

    private void Sat(int col) {
        for (int i = 0; i < 5; i++) {
            courses[col][i] = null;
        }

    }

    private void Fri(int col) {
        Course c1 = new Course("创业就业指导实践",1,10,0,"中心楼213");
        Course c2 = new Course("算法设计与分析",1,16,0,"东楼209");
        Course c3 = new Course("移动设备软件开发实训",1,15,0,"实2#212");
        courses[col][0] = c1;
        courses[col][1] = c2;
        courses[col][3] = c3;

    }

    private void Thur(int col) {
        Course c1 = null;
        if (day(12)){
            c1 = new Course("数据库原理及应用",1,12,0,"实3#110");
        }else {
            c1 = new Course("数据库原理及应用课程设计",14,18,0,"实3#110");
        }
        Course c2 = null;
        if (day(12)){
            c2 = new Course("计算机操作系统",1,12,0,"东楼206");
        }else {
            c2 = new Course("计算机操作系统",13,16,0,"实3#108");
        }
        Course c3 = new Course("数值分析",1,15,1,"实2#209");
        Course c4 = new Course("软件工程",2,16,2,"实2#204");
        courses[col][0] = c1;
        courses[col][1] = c2;
        courses[col][2] = c3;
        courses[col][3] = c4;
    }

    private void Wed(int col) {
        Course c1 = new Course("Linux操作系统",1,16,0,"实3#110");
        courses[col][0] = c1;
    }

    private void Tues(int col) {
        Course c1 = new Course("复变函数与积分变换",1,16,0,"东楼210");
        Course c2 = new Course("数值分析",1,16,0,"西楼505");
        Course c3 = new Course("嵌入式系统及应用",1,16,0,"实2#204");
        courses[col][0] = c1;
        courses[col][1] = c2;
        courses[col][3] = c3;
    }

    private void Mon(int col) {
        Course c1 = null;
        if (day(12)){
            c1 = new Course("数据库原理及应用",1,12,0,"实3#110");
        }else {
            c1 = new Course("数据库原理及应用课程设计",14,18,0,"实3#110");
        }
        Course c2 = new Course("软件工程",1,16,0,"西楼507");
        Course c3 = new Course("移动设备软件开发实训",1,15,0,"实2#212");
        courses[col][0] = c1;
        courses[col][1] = c2;
        courses[col][3] = c3;
    }
    private boolean day(int i) {
        return day / 7 < i;
    }

    public static Course[][] getCourses() {
        return courses;
    }

    public static void setCourses(Course[][] courses) {
        Courses.courses = courses;
    }

    public void setDay(Long day) {
        this.day = day;
    }

    public Long getDay() {
        return day;
    }
    public static Course getCourse(int x,int y) {
        return courses[x][y];
    }

}
